﻿using GalaSoft.MvvmLight.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace MvvmLightDemo.ViewModel
{
    public class NavigationService : IFrameNavigationService
    {
        public Dictionary<string, Type> PageDictionary = new Dictionary<string, Type>();
        public Frame MainFrame { get; set; }

        string INavigationService.CurrentPageKey { get; }

        public void Configure(string key, Type page)
        {
            PageDictionary.Add(key, page);
        }
        public void GoBack()
        {
            if (MainFrame.CanGoBack)
                MainFrame.GoBack();
        }
        public void NavigateTo(string pageKey)
        {
            MainFrame.Navigate(PageDictionary[pageKey]);
        }

        public void NavigateTo(string pageKey, object parameter)
        {
            MainFrame.Navigate(PageDictionary[pageKey], parameter);
        }
    }
}
